package com.safeneeds.linguimana.web;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.safeneeds.linguimana.dto.DataStorePort;
import com.safeneeds.linguimana.dto.StarDataStorePort;
import com.safeneeds.linguimana.entity.EntityPortGlutOnduty;
import com.safeneeds.linguimana.entity.PortGlutOnduty;
import com.safeneeds.linguimana.entity.PortGlutStar;
import com.safeneeds.linguimana.entity.PortNews;
import com.safeneeds.linguimana.entity.PortNewsCate;
import com.safeneeds.linguimana.entity.PortNewsCateMap;
import com.safeneeds.linguimana.ser.IBgDutyService;
import com.safeneeds.linguimana.ser.IBgStarService;
import com.safeneeds.util.base.BaseAction;
import com.safeneeds.util.base.IUserInfo;
import com.safeneeds.util.base.RetType;
import com.safeneeds.util.other.StringUtil;
import com.safeneeds.util.page.PageInfo;
/**
 * 门户新闻管理
 * @author zqq
 * @date 2017年2月21日
 * desc:用于处理最美警星模块请求
 */
@Controller
@RequestMapping("bgPortGlutStar")
public class BgGlutStarAction extends BaseAction {

	@Resource(name="bgStarService")
	private IBgStarService bgStarService;
	
	@RequestMapping("listStar.do")
	public String listStar(ModelMap modelMap, PageInfo pageInfo, StarDataStorePort starDataStorePort){
		
		if(starDataStorePort != null){
			//获取分页数据
			pageInfo = bgStarService.listStarPage(pageInfo, starDataStorePort);
			
		}
		modelMap.put("pageInfo", pageInfo);
		modelMap.put("stardataStore", starDataStorePort);
		
		return getViewsModelPathSys("portmana/bg/glutstar/starList"); 
	}
	/**
	 * 新增最美警星登录
	 * 
	 * @return
	 */
	@RequestMapping("addStarLogin.do")
	public String addStar(ModelMap modelMap, PortGlutStar portGlutStar, StarDataStorePort starDataStorePort){
		if(!StringUtil.isEmpty(portGlutStar.getStarId())){
			portGlutStar = bgStarService.getportGlutStar(portGlutStar.getStarId());
			modelMap.put("star", portGlutStar);
			System.out.println("twrtwretw"+portGlutStar.toString());
		}
		return getViewsModelPathSys("portmana/bg/glutstar/addStar");
	}
	
	/**
	 * 添加、更新警星最美
	 * @return
	 */
	@ResponseBody
	@RequestMapping("addStar.do")
	public RetType addStar(HttpServletRequest request, ModelMap modelMap, PortGlutStar portGlutStar,String image){
		if(!StringUtil.isEmpty(image)){
			portGlutStar.setImageUrl(image);
		}
		System.out.println(portGlutStar);
		
		return bgStarService.addOrUpdateStar(portGlutStar);
	}
	
	/**
	 * 删除最美警星
	 * @param modelMap
	 * @return
	 */
	@ResponseBody
	@RequestMapping("delStar.do")
	public RetType delStar(String ids){
		
		return bgStarService.deleteStarById(ids);
	}
}
